# 本test提供了2种创进程的方法

from multiprocessing.context import Process
import os
import time

# 子进程要执行的代码
def run_proc(name):
    print(name)
    print(os.getpid())

# 自定义进程类
class MyProcess(Process):
    def __init__(self):
        Process.__init__(self)

    def run(self):
        print('我是子进程P2')

if __name__=='__main__':
    print(os.getpid())                               # 父进程的pid
    p1 = Process(target=run_proc, args=('test',))     # 传'test'进去
    p1.start()   
    p1.join()                                         # 等p进程跑完了才去跑父进程

    p2 = MyProcess()
    p2.start()
    p2.join()




